﻿namespace Nomo.UnityCoreModule.Nodes
{
    /// <summary>
    /// 界面监控器。
    /// </summary>
    public sealed class NodeMonitor : UnityEngine.MonoBehaviour
    {
        [UnityEngine.SerializeField] private System.Collections.Generic.List<Node> preOrderAll;
        [UnityEngine.SerializeField] private System.Collections.Generic.List<Node> levelOrderAll;
        [UnityEngine.SerializeField] private System.Collections.Generic.List<Node> viewOrderAll;

        private bool _isEditor;

        private void Awake()
        {
            _isEditor = UnityEngine.Application.isEditor;
        }

        private void Update()
        {
            if (!_isEditor)
            {
                return;
            }

            preOrderAll.Clear();
            levelOrderAll.Clear();
            viewOrderAll.Clear();

            preOrderAll.AddRange(Node.PreOrderAll());
            levelOrderAll.AddRange(Node.LevelOrderAll());
            viewOrderAll.AddRange(Node.ViewOrderAll());
        }
    }
}
